package com.godpaper.the5elements.support.AStar
{
	
	public class Waypoint
	{
		//used by the BFS so a waypoint is not processed multiple times
		public var marked:Boolean;
		
		//the distance from the start to this waypoint
		public var distance:Number;
		
		public var prev:Waypoint;
		
		//the x/y coordinates of this waypoint for distance calculation
		/*public var x:Number;
		public var y:Number;*/
		
		//the index of the graphnode instance that stores this waypoint
		public var graphNodeIndex:int;
		
		public function Waypoint(graphNodeIndex:int)
		{
			this.graphNodeIndex = graphNodeIndex;
			init();
		}
		
		public function setPos(x:Number, y:Number):void
		{
			this.x = x;
			this.y = y;
		}
		
		public function distanceTo(wp:Waypoint):Number
		{
			var dx:Number = wp.x - x;
			var dy:Number = wp.y - y;
			return Math.sqrt((dx * dx) + (dy * dy));
		}
		
		public function init():void
		{
			marked = false;
			distance = 0;
			prev = null;
		}
	}
}